package basic.thread.again;

/**
 * @author bingo
 * @Description
 * @Date 2018/5/22
 */
public class Thread1 implements  Runnable {

    @Override
    public void run() {
        int i=0;
        while (i++ < 20) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + "--print:" + i);
        }
    }

    public static void main(String[] args) {
        Thread t1 = new Thread(new Thread1());
        t1.setName("A");

        Thread t2 = new Thread(new Thread1());
        t2.setName("B");

        t1.start();
        try {
            t1.join(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        t2.start();
        }
}



